home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume24 / mkid2 / part03 < prev    next >
Encoding:
Internet Message Format  |  1991-10-09  |  36.2 KB

  1. Subject:  v24i091:  Program identifier database tools, Part03/07
  2. Newsgroups: comp.sources.unix
  3. Approved: rsalz@uunet.UU.NET
  4. X-Checksum-Snefru: 9a2d4815 16786dd0 90eb7678 74d3a259
  5.  
  6. Submitted-by: Tom Horsley <tom@hcx2.ssd.csd.harris.com>
  7. Posting-number: Volume 24, Issue 91
  8. Archive-name: mkid2/part03
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 3 (of 7)."
  17. # Contents:  Makefile getscan.c iiddef.h lid.1 scan-asm.c
  18. # Wrapped by tom@hcx2 on Tue Feb 26 10:03:03 1991
  19. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  20. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  21.   echo shar: Will not clobber existing file \"'Makefile'\"
  22. else
  23. echo shar: Extracting \"'Makefile'\" \(7491 characters\)
  24. sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  25. X#!/bin/make -f
  26. X
  27. X# Copyright (c) 1986, Greg McGary
  28. X# @(#)makefile    1.3 86/11/06
  29. X
  30. X# --------------------------------------------------------------------
  31. X# System Dependent Configuration:
  32. X#   Choose a pre-packaged set of options below, or roll your own.
  33. X#   The relevant options are as follows:
  34. X#
  35. X# * If you have the `PW' library which includes the regular-expression
  36. X#   funcions regcmp(3) and regex(3), then use `-DREGEX' in DEFS, and
  37. X#   `-lPW' in LIBS.  If you have the regular-expression functions
  38. X#   re_comp(3) and re_exec(3), use `-DRE_EXEC' in DEFS.  If you don't
  39. X#   have any regular-expression functions, don't add either to DEFS.
  40. X#
  41. X# * If you do not have the 4.2 directory access libraries, add `-lndir'
  42. X#   to LIBS, and define `-DNDIR' in DEFS. 
  43. X#
  44. X# * If your string libraries have index(3) and rindex(3) instead of
  45. X#   strchr(3) and strrchr(3), use `-DRINDEX' in DEFS.
  46. X#
  47. X# * If your compiler chokes on pointers to functions returning void,
  48. X#   use `-Dvoid=int' in DEFS.
  49. X#
  50. X# * If you have setlinebuf(3) in your stdio to set line-buffering on
  51. X#   a stream, use `-DERRLINEBUF' in DEFS.
  52. X#
  53. X# * If you have a System-III/V terminal driver, define `TERMIO' in DEFS.
  54. X#
  55. X# * If you have ranlib(1), define `RANLIB' as such.  If you don't have
  56. X#   it, set `RANLIB' to something harmless like `@:', or `echo'
  57. X#
  58. X# * If you want lists of file names compressed with csh {} notation by
  59. X#   default, set -DCRUNCH_DEFAULT=1. If you want files printed with no
  60. X#   "crunching", set -DCRUNCH_DEFAULT=0. (The -k and -g options allow
  61. X#   runtime control regardless of the builtin default).
  62. X#
  63. X# * If your system supports the alloca() function for allocating space
  64. X#   on the stack, defined -DUSE_ALLOCA
  65. X# --------------------------------------------------------------------
  66. X
  67. XDEFS    =    -Dvoid=int -DREGEX -DTERMIO    # typical System-V defs
  68. X# DEFS    =    -DREGEX -DNDIR -DTERMIO    # typical System-V defs
  69. X# DEFS    =    -Dvoid=int -DRINDEX -DRE_EXEC -DNDIR    # typical V7 defs
  70. X# DEFS    =    -Dvoid=int -DRINDEX -DRE_EXEC -DERRLINEBUF    # BSD defs
  71. X
  72. XLIBS    =    -lc -lPW    # typical System-V libs
  73. X# LIBS    =    -lndir -lPW    # typical System-V libs
  74. X# LIBS    =    -lndir    # typical V7 libs
  75. X# LIBS    =    # typical BSD libs (none)
  76. X
  77. XRANLIB    =    @:    # system doesn't have ranlib (Sys-V)
  78. X# RANLIB    =    ranlib    # system has ranlib (typically V7 & BSD)
  79. X
  80. XCRUNCH  =       -DCRUNCH_DEFAULT=1      # Original default - crunch file names
  81. X#CRUNCH =       -DCRUNCH_DEFAULT=0      # Don't crunch names by default
  82. X
  83. XALLOCA  =       -DUSE_ALLOCA            # alloca support exists on system
  84. X#ALLOCA =                               # system has no alloca() function
  85. X
  86. X# --------------------------------------------------------------------
  87. X# Compilation / Loading options:
  88. X#   Choose options to generate a system as an installed product,
  89. X#   for debugging, or for performance profiling.
  90. X# --------------------------------------------------------------------
  91. X
  92. X# CCFLG    =    -g -DDEBUG     # debugging
  93. X# CCFLG    =    -p    # profiling
  94. XCCFLG    =    -O3 -g    # production
  95. X
  96. X# LDFLG    =    -g    # debugging
  97. X# LDFLG    =    -p    # profiling
  98. XLDFLG    =    # production
  99. X
  100. XCC    =    hc
  101. X
  102. X# --------------------------------------------------------------------
  103. X
  104. XSHELL =        /bin/ksh
  105. XTARGETS =    libid.a $(PROGS)
  106. XPROGS =        mkid lid idx fid iid $(LIDLINKS)
  107. XDESTINATION_DIR = /usr/local
  108. XMANDIR =        /usr/catman/local_man/man1
  109. X
  110. XLIDLINKS =     gid aid eid pid
  111. XCFLAGS =    $(CCFLG) -I. $(DEFS) $(CRUNCH) $(ALLOCA)
  112. XLDFLAGS =    $(LDFLG) libid.a $(LIBS)
  113. X
  114. XOFILES =    init.o getscan.o scan-c.o scan-asm.o bsearch.o hash.o \
  115. X        bitops.o basename.o gets0.o getsFF.o paths.o opensrc.o \
  116. X        stoi.o uerror.o document.o bitcount.o wmatch.o bitsvec.o \
  117. X        tty.o bzero.o scan-text.o cannoname.o kshgetwd.o unsymlink.o
  118. X
  119. XTEXJUNK=id.aux id.cp id.cps id.dvi id.fn id.fns id.ky id.kys id.log id.pg \
  120. X    id.pgs id.toc id.tp id.tps id.vr id.vrs id-info
  121. X
  122. X# --------------------------------------------------------------------
  123. X
  124. Xall:        $(TARGETS)
  125. X
  126. Xlibid.a:    $(OFILES)
  127. X        ar rv $@ $?
  128. X        $(RANLIB) $@
  129. X
  130. Xmkid:        mkid.o libid.a
  131. X        $(CC) -o $@ $@.o $(LDFLAGS)
  132. X
  133. Xfid:        fid.o libid.a
  134. X        $(CC) -o $@ $@.o $(LDFLAGS)
  135. X
  136. Xlid:        lid.o libid.a
  137. X        $(CC) -o $@ $@.o $(LDFLAGS)
  138. X
  139. Xidx:        idx.o libid.a
  140. X        $(CC) -o $@ $@.o $(LDFLAGS)
  141. X
  142. Xiid:        iid.o iidfun.o
  143. X        $(CC) -o iid iid.o iidfun.o $(LDFLG) $(LIBS)
  144. X
  145. Xiid.c:        iid.y
  146. X        rm -f iid.c
  147. X        yacc iid.y
  148. X        mv y.tab.c iid.c
  149. X
  150. Xiidfun.o:    iidfun.c iiddef.h
  151. X
  152. Xiid.o:        iid.c iiddef.h
  153. X        $(CC) $(CFLAGS) -DDEF -c iid.c
  154. X
  155. X$(LIDLINKS): lid
  156. X        -/bin/rm -f $@
  157. X        ln lid $@
  158. X
  159. Xinstall: installbin installman
  160. X
  161. Xinstallman:    fid.1 iid.1 lid.1 mkid.1
  162. X        cp fid.1 iid.1 lid.1 mkid.1 $(MANDIR)
  163. X        cd $(MANDIR) ; rm -f fid.1.z iid.1.z lid.1.z mkid.1.z aid.1.z \
  164. X                             gid.1.z eid.1.z
  165. X        cd $(MANDIR) ; chmod 666 fid.1 iid.1 lid.1 mkid.1
  166. X        cd $(MANDIR) ; mantocatman fid.1
  167. X        cd $(MANDIR) ; mantocatman iid.1
  168. X        cd $(MANDIR) ; mantocatman lid.1
  169. X        cd $(MANDIR) ; mantocatman mkid.1
  170. X        cd $(MANDIR) ; rm -f fid.1 iid.1 lid.1 mkid.1
  171. X
  172. Xinstallbin: $(PROGS)
  173. X        chmod 777 $(PROGS)
  174. X        -mv $(DESTINATION_DIR)/mkid $(DESTINATION_DIR)/OLDmkid
  175. X        -mv $(DESTINATION_DIR)/lid $(DESTINATION_DIR)/OLDlid
  176. X        -mv $(DESTINATION_DIR)/idx $(DESTINATION_DIR)/OLDidx
  177. X        -mv $(DESTINATION_DIR)/fid $(DESTINATION_DIR)/OLDfid
  178. X        -mv $(DESTINATION_DIR)/gid $(DESTINATION_DIR)/OLDgid
  179. X        -mv $(DESTINATION_DIR)/aid $(DESTINATION_DIR)/OLDaid
  180. X        -mv $(DESTINATION_DIR)/eid $(DESTINATION_DIR)/OLDeid
  181. X        -mv $(DESTINATION_DIR)/pid $(DESTINATION_DIR)/OLDpid
  182. X        -mv $(DESTINATION_DIR)/iid $(DESTINATION_DIR)/OLDiid
  183. X        -rm -f $(DESTINATION_DIR)/iid.help
  184. X        cp mkid $(DESTINATION_DIR)/mkid
  185. X        cp lid $(DESTINATION_DIR)/lid
  186. X        cp idx $(DESTINATION_DIR)/idx
  187. X        cp fid $(DESTINATION_DIR)/fid
  188. X        cp iid $(DESTINATION_DIR)/iid
  189. X        cp iid.help $(DESTINATION_DIR)/iid.help
  190. X        chmod 444 $(DESTINATION_DIR)/iid.help
  191. X        ln $(DESTINATION_DIR)/lid $(DESTINATION_DIR)/gid
  192. X        ln $(DESTINATION_DIR)/lid $(DESTINATION_DIR)/aid
  193. X        ln $(DESTINATION_DIR)/lid $(DESTINATION_DIR)/eid
  194. X        ln $(DESTINATION_DIR)/lid $(DESTINATION_DIR)/pid
  195. X
  196. Xclean:
  197. X        rm -f $(TARGETS) *.o iid.c core a.out $(TEXJUNK)
  198. X
  199. Xid.tar:
  200. X        cd ..; tar cvbf 20 id/id.tar id/*.[ch1-8] id/makefile id/TODO id/TUTORIAL
  201. X
  202. Xid.tar.Z:    id.tar
  203. X        compress -b 14 <id.tar >id.tar.Z
  204. X
  205. Xid.shar:    id.shar-1 id.shar-2 id.shar-3
  206. X
  207. Xid.shar-1:
  208. X        shar $(SHARFLAGS) TUTORIAL TODO makefile *.h *.[1-8] >$@
  209. X
  210. Xid.shar-2:
  211. X        shar $(SHARFLAGS) [a-l]*.c >$@
  212. X
  213. Xid.shar-3:
  214. X        shar $(SHARFLAGS) [m-z]*.c >$@
  215. X
  216. Xdebug:
  217. X    make CCFLG='-g -DDEBUG' LDFLG='-g'
  218. X
  219. XID::
  220. X    /bin/rm -f ID
  221. X    mkid *.[chy]
  222. X
  223. XTAGS::
  224. X    /bin/rm -f TAGS
  225. X    etags -tw *.[chy]
  226. X
  227. X# TeX stuff - these actions count on several things being installed on
  228. X# your system:
  229. X#
  230. X# tex - the document processor
  231. X# texinfo.tex - the texinfo macro package used to format the document
  232. X# texindex - the index sorting program used to generate the index
  233. X# makeinfo - the program to turn texinfo files into online documentation
  234. X#
  235. X# A tex distribution tape can be obtained from the University of Washington.
  236. X# send email to: elisabet@max.u.washington.edu for more info.
  237. X#
  238. X# The other texinfo tools are part of the Gnuemacs distribution and can
  239. X# be obtained via FTP from prep.ai.mit.edu
  240. X
  241. X# Make the online info file by running makeinfo - texinfo-format-buffer from
  242. X# within emacs probably will not work very well.
  243. Xid-info: id.texinfo
  244. X    makeinfo id.texinfo
  245. X
  246. X# If you are running TeX from a clean directory, need to run once to get
  247. X# the initial .aux file with the cross reference info in it.
  248. Xid.aux: id.texinfo
  249. X    tex id.texinfo
  250. X    texindex id.??
  251. X
  252. X# Running TeX twice here is probably overkill, but it makes absolutely sure
  253. X# the index agrees with the actual location of text.
  254. Xid.dvi: id.aux
  255. X    tex id.texinfo
  256. X    texindex id.??
  257. X    tex id.texinfo
  258. END_OF_FILE
  259. if test 7491 -ne `wc -c <'Makefile'`; then
  260.     echo shar: \"'Makefile'\" unpacked with wrong size!
  261. fi
  262. # end of 'Makefile'
  263. fi
  264. if test -f 'getscan.c' -a "${1}" != "-c" ; then 
  265.   echo shar: Will not clobber existing file \"'getscan.c'\"
  266. else
  267. echo shar: Extracting \"'getscan.c'\" \(7141 characters\)
  268. sed "s/^X//" >'getscan.c' <<'END_OF_FILE'
  269. X/* Copyright (c) 1986, Greg McGary */
  270. Xstatic char sccsid[] = "@(#)getscan.c    1.1 86/10/09";
  271. X
  272. X#include    <stdio.h>
  273. X#include    <string.h>
  274. X#include    <id.h>
  275. X#include    <ctype.h>
  276. X#include    <extern.h>
  277. X
  278. Xchar *getLanguage();
  279. Xchar *(*getScanner())();
  280. Xvoid setScanArgs();
  281. X
  282. Xstatic struct sufftab *suffSlot();
  283. Xstatic struct langtab *langSlot();
  284. Xstatic void sorryNoScan();
  285. X
  286. Xvoid setAdaArgs(lang) { sorryNoScan(lang); }
  287. Xchar *getAdaId() { setAdaArgs("ada"); return NULL; }
  288. X
  289. Xvoid setPascalArgs(lang) { sorryNoScan(lang); }
  290. Xchar *getPascalId() { setPascalArgs("pascal"); return NULL; }
  291. X
  292. Xvoid setLispArgs(lang) { sorryNoScan(lang); }
  293. Xchar *getLispId() { setLispArgs("lisp"); return NULL; }
  294. X
  295. Xstruct langtab {
  296. X    struct langtab    *lt_next;
  297. X    char    *lt_name;
  298. X    char    *(*lt_getid)();
  299. X    void    (*lt_setargs)();
  300. X    char    *lt_filter;
  301. X};
  302. X
  303. Xstruct sufftab {
  304. X    struct sufftab    *st_next;
  305. X    char    *st_suffix;
  306. X    struct langtab *st_lang;
  307. X};
  308. X
  309. X
  310. Xstruct langtab langtab[] = {
  311. X#define    SCAN_C        (&langtab[0])
  312. X{&langtab[1],    "c",        getCId,        setCArgs,    NULL},
  313. X#define    SCAN_ASM    (&langtab[1])
  314. X{&langtab[2],    "asm",        getAsmId,    setAsmArgs,    NULL},
  315. X#define    SCAN_ADA    (&langtab[2])
  316. X{&langtab[3],    "ada",        getAdaId,    setAdaArgs,    NULL},
  317. X#define    SCAN_PASCAL    (&langtab[3])
  318. X{&langtab[4],    "pascal",    getPascalId,    setPascalArgs,    NULL},
  319. X#define    SCAN_LISP    (&langtab[4])
  320. X{&langtab[5],    "lisp",        getLispId,    setLispArgs,    NULL},
  321. X#define    SCAN_TEXT    (&langtab[5])
  322. X{&langtab[6],    "text",        getTextId,    setTextArgs,    NULL},
  323. X#define SCAN_VHIL    (&langtab[6])
  324. X{&langtab[7],    "vhil",        getVhilId,    setCArgs,    NULL},
  325. X#define SCAN_TEX    (&langtab[7])
  326. X{&langtab[8],    "tex",        getTextId,    setTextArgs,    "detex -i %s"},
  327. X#define SCAN_ROFF    (&langtab[8])
  328. X{&langtab[9],    "roff",        getTextId,    setTextArgs,    "sed '/^\\.so/d' < %s | deroff"},
  329. X#define SCAN_CATMAN    (&langtab[9])
  330. X{&langtab[10],    "catman",    getTextId,    setTextArgs,    "pcat %s | col -b"},
  331. X{ NULL, NULL, NULL, NULL, NULL}
  332. X};
  333. X
  334. X/*
  335. X    This is a rather incomplete list of default associations
  336. X    between suffixes and languages.  You may add more to the
  337. X    default list, or you may define them dynamically with the
  338. X    `-S<suff>=<lang>' argument to mkid(1) and idx(1).  e.g. to
  339. X    associate a `.ada' suffix with the Ada language, use
  340. X    `-S.ada=ada'
  341. X*/
  342. Xstruct sufftab sufftab[] = {
  343. X{&sufftab[1],    ".c",    SCAN_C        },
  344. X{&sufftab[2],    ".h",    SCAN_C        },
  345. X{&sufftab[3],    ".y",    SCAN_C        },
  346. X{&sufftab[4],    ".s",    SCAN_ASM    },
  347. X{&sufftab[5],    ".p",    SCAN_PASCAL    },
  348. X{&sufftab[6],    ".pas",    SCAN_PASCAL    },
  349. X{&sufftab[7],    ".x",    SCAN_VHIL    },
  350. X{&sufftab[8],    ".l",    SCAN_C        },    /* lex */
  351. X{&sufftab[9],    ".doc",    SCAN_TEXT    },
  352. X{&sufftab[10],    ".1",    SCAN_ROFF    },
  353. X{&sufftab[11],    ".tex",    SCAN_TEX    },
  354. X{&sufftab[12],    ".z",    SCAN_CATMAN    },
  355. X{&sufftab[13],    "",    SCAN_TEXT    },    /* default to text */
  356. X{ NULL, NULL, NULL },
  357. X};
  358. X
  359. X/*
  360. X    Return an index into the langtab array for the given suffix.
  361. X*/
  362. Xstatic struct sufftab *
  363. XsuffSlot(suffix)
  364. X    register char    *suffix;
  365. X{
  366. X    register struct sufftab    *stp;
  367. X
  368. X    if (suffix == NULL)
  369. X        suffix = "";
  370. X
  371. X    for (stp = sufftab; stp->st_next; stp = stp->st_next)
  372. X        if (strequ(stp->st_suffix, suffix))
  373. X            return stp;
  374. X    return stp;
  375. X}
  376. X
  377. Xstatic struct langtab *
  378. XlangSlot(lang)
  379. X    char        *lang;
  380. X{
  381. X    register struct langtab    *ltp;
  382. X
  383. X    if (lang == NULL)
  384. X        lang = "";
  385. X
  386. X    for (ltp = langtab; ltp->lt_next; ltp = ltp->lt_next)
  387. X        if (strequ(ltp->lt_name, lang))
  388. X            return ltp;
  389. X    return ltp;
  390. X}
  391. X
  392. Xchar *
  393. XgetLanguage(suffix)
  394. X    char        *suffix;
  395. X{
  396. X    struct sufftab    *stp;
  397. X
  398. X    if ((stp = suffSlot(suffix))->st_next == NULL)
  399. X        return NULL;
  400. X    return (stp->st_lang->lt_name);
  401. X}
  402. X
  403. Xchar *
  404. XgetFilter(suffix)
  405. X    char        *suffix;
  406. X{
  407. X    struct sufftab    *stp;
  408. X
  409. X    if ((stp = suffSlot(suffix))->st_next == NULL)
  410. X        return NULL;
  411. X    return (stp->st_lang->lt_filter);
  412. X}
  413. X
  414. Xchar *(*
  415. XgetScanner(lang))()
  416. X    char        *lang;
  417. X{
  418. X    struct langtab    *ltp;
  419. X
  420. X    if ((ltp = langSlot(lang))->lt_next == NULL)
  421. X        return NULL;
  422. X    return (ltp->lt_getid);
  423. X}
  424. X
  425. Xstatic void
  426. Xusage()
  427. X{
  428. X    fprintf(stderr, "Usage: %s [-S<suffix>=<lang>] [+S(+|-)<arg>] [-S<lang>(+|-)<arg>] [-S<lang>/<lang>/<filter>]\n", MyName);
  429. X    exit(1);
  430. X}
  431. Xvoid
  432. XsetScanArgs(op, arg)
  433. X    int        op;
  434. X    char        *arg;
  435. X{
  436. X    struct langtab    *ltp, *ltp2;
  437. X    struct sufftab    *stp;
  438. X    char        *lhs, *lhs2;
  439. X    int        count = 0;
  440. X
  441. X    lhs = arg;
  442. X    while (isalnum(*arg) || *arg == '.')
  443. X        arg++;
  444. X
  445. X    if (strequ(lhs, "?=?")) {
  446. X        for (stp = sufftab; stp->st_next; stp = stp->st_next) {
  447. X            printf("%s%s=%s", (count++>0)?", ":"", stp->st_suffix, stp->st_lang->lt_name);
  448. X            if (stp->st_lang->lt_filter)
  449. X                printf(" (%s)", stp->st_lang->lt_filter);
  450. X        }
  451. X        if (count)
  452. X            putchar('\n');
  453. X        return;
  454. X    }
  455. X
  456. X    if (strnequ(lhs, "?=", 2)) {
  457. X        lhs += 2;
  458. X        if ((ltp = langSlot(lhs))->lt_next == NULL) {
  459. X            printf("No scanner for language `%s'\n", lhs);
  460. X            return;
  461. X        }
  462. X        for (stp = sufftab; stp->st_next; stp = stp->st_next)
  463. X            if (stp->st_lang == ltp) {
  464. X                printf("%s%s=%s", (count++>0)?", ":"", stp->st_suffix, ltp->lt_name);
  465. X                if (stp->st_lang->lt_filter)
  466. X                    printf(" (%s)", stp->st_lang->lt_filter);
  467. X            }
  468. X        if (count)
  469. X            putchar('\n');
  470. X        return;
  471. X    }
  472. X
  473. X    if (strequ(arg, "=?")) {
  474. X        lhs[strlen(lhs)-2] = '\0';
  475. X        if ((stp = suffSlot(lhs))->st_next == NULL) {
  476. X            printf("No scanner assigned to suffix `%s'\n", lhs);
  477. X            return;
  478. X        }
  479. X        printf("%s=%s", stp->st_suffix, stp->st_lang->lt_name);
  480. X        if (stp->st_lang->lt_filter)
  481. X            printf(" (%s)",stp->st_lang->lt_filter);
  482. X        printf("\n");
  483. X        return;
  484. X    }
  485. X
  486. X    if (*arg == '=') {
  487. X        *arg++ = '\0';
  488. X        
  489. X        if ((ltp = langSlot(arg))->lt_next == NULL) {
  490. X            fprintf(stderr, "%s: Language undefined: %s\n", MyName, arg);
  491. X            return;
  492. X        }
  493. X        if ((stp = suffSlot(lhs))->st_next == NULL) {
  494. X            stp->st_suffix = lhs;
  495. X            stp->st_lang = ltp;
  496. X            stp->st_next = NEW(struct sufftab);
  497. X        } else if (!strequ(arg, stp->st_lang->lt_name)) {
  498. X            fprintf(stderr, "%s: Note: `%s=%s' overrides `%s=%s'\n", MyName, lhs, arg, lhs, stp->st_lang->lt_name);
  499. X            stp->st_lang = ltp;
  500. X        }
  501. X        return;
  502. X    } else if (*arg == '/') {
  503. X        *arg++ = '\0';
  504. X        if ((ltp = langSlot(lhs))->lt_next == NULL) {
  505. X            ltp->lt_name = lhs;
  506. X            ltp->lt_getid = getTextId;
  507. X            ltp->lt_setargs = setTextArgs;
  508. X            ltp->lt_filter = NULL;
  509. X            ltp->lt_next = NEW(struct langtab);
  510. X        }
  511. X        lhs2 = arg;
  512. X        arg = strchr(arg, '/');
  513. X        if (arg == NULL) {
  514. X            ltp2 = ltp;
  515. X        } else {
  516. X            *arg++ = '\0';
  517. X            if ((ltp2 = langSlot(lhs2))->lt_next == NULL) {
  518. X                fprintf(stderr,"%s: language %s not defined.\n", MyName, lhs2);
  519. X                ltp2 = ltp;
  520. X            }
  521. X        }
  522. X        ltp->lt_getid = ltp2->lt_getid;
  523. X        ltp->lt_setargs = ltp2->lt_setargs;
  524. X        if ((ltp->lt_filter != NULL) && (!strequ(arg, ltp->lt_filter))){
  525. X            fprintf(stderr, "%s: Note: `%s/%s' overrides `%s/%s'\n", MyName, lhs, arg, lhs, ltp->lt_filter);
  526. X        }
  527. X        ltp->lt_filter = arg;
  528. X        return;
  529. X    }
  530. X    
  531. X    if (op == '+') {
  532. X        switch (op = *arg++)
  533. X        {
  534. X        case '+':
  535. X        case '-':
  536. X        case '?':
  537. X            break;
  538. X        default:
  539. X            usage();
  540. X        }
  541. X        for (ltp = langtab; ltp->lt_next; ltp = ltp->lt_next)
  542. X            (*ltp->lt_setargs)(NULL, op, arg);
  543. X        return;
  544. X    }
  545. X
  546. X    if (*arg == '-' || *arg == '+' || *arg == '?') {
  547. X        op = *arg;
  548. X        *arg++ = '\0';
  549. X        
  550. X        if ((ltp = langSlot(lhs))->lt_next == NULL) {
  551. X            fprintf(stderr, "%s: Language undefined: %s\n", MyName, lhs);
  552. X            return;
  553. X        }
  554. X        (*ltp->lt_setargs)(lhs, op, arg);
  555. X        return;
  556. X    }
  557. X
  558. X    usage();
  559. X}
  560. X
  561. X/*
  562. X    Notify user of unimplemented scanners.
  563. X*/
  564. Xstatic void
  565. XsorryNoScan(lang)
  566. X    char        *lang;
  567. X{
  568. X    if (lang == NULL)
  569. X        return;
  570. X    fprintf(stderr, "Sorry, no scanner is implemented for %s...\n", lang);
  571. X}
  572. END_OF_FILE
  573. if test 7141 -ne `wc -c <'getscan.c'`; then
  574.     echo shar: \"'getscan.c'\" unpacked with wrong size!
  575. fi
  576. # end of 'getscan.c'
  577. fi
  578. if test -f 'iiddef.h' -a "${1}" != "-c" ; then 
  579.   echo shar: Will not clobber existing file \"'iiddef.h'\"
  580. else
  581. echo shar: Extracting \"'iiddef.h'\" \(6331 characters\)
  582. sed "s/^X//" >'iiddef.h' <<'END_OF_FILE'
  583. X/* Definitions used by the iid program.
  584. X */
  585. X
  586. X#include <stdio.h>
  587. X#include <ctype.h>
  588. X#include <string.h>
  589. Xextern char * getenv() ;
  590. Xextern int getopt() ;
  591. Xextern char * optarg ;
  592. Xextern int optind ;
  593. X#define TRUE 1
  594. X#define FALSE 0
  595. X
  596. X#ifdef DEF
  597. X#define EXTERN
  598. X#define INIT(a) =(a)
  599. X#else
  600. X#define EXTERN extern
  601. X#define INIT(a)
  602. X#endif
  603. X
  604. X#define BITS_PER_BYTE 8                /* used by bit set manipulation */
  605. X
  606. X#define HASH_SIZE 947                  /* size of hash table for file names */
  607. X
  608. X#ifndef HELPFILE
  609. X#define HELPFILE "/usr/local/iid.help" /* The help file location */
  610. X#endif
  611. X
  612. X#define INIT_FILES 8000                /* start with bits for this many */
  613. X
  614. X#define INIT_SETSPACE 500              /* start with room for this many */
  615. X
  616. X#define MAX(a,b) (((a)<(b))?(b):(a))
  617. X
  618. X#define MAXCMD 1024                    /* input command buffer size */
  619. X
  620. X#define MIN(a,b) (((a)>(b))?(b):(a))
  621. X
  622. X#ifndef PAGER
  623. X#define PAGER "pg"
  624. X#endif
  625. X
  626. X#define PROMPT "iid> "
  627. X
  628. X/* set_type is the struct defining a set of file names
  629. X * The file names are stored in a symbol table and assigned
  630. X * unique numbers. The set is a bit set of file numbers.
  631. X * One of these set structs is calloced for each new set
  632. X * constructed, the size allocated depends on the max file
  633. X * bit number. An array of pointers to sets are kept to
  634. X * represent the complete set of sets.
  635. X */
  636. X
  637. Xtypedef struct set_struct {
  638. X   char *                 set_desc ;   /* string describing the set */
  639. X   int                    set_num ;    /* the set number */
  640. X   int                    set_size ;   /* number of long words in set */
  641. X   unsigned long int      set_tail ;   /* set extended with these bits */
  642. X   unsigned long int      set_data[1] ;/* the actual set data (calloced) */
  643. X} set_type ;
  644. X
  645. X/* id_type is one element of an id_list
  646. X */
  647. X
  648. Xtypedef struct id_struct {
  649. X   struct id_struct *     next_id ;    /* Linked list of IDs */
  650. X   char                   id [ 1 ] ;   /* calloced data holding id string */
  651. X} id_type ;
  652. X
  653. X/* id_list_type is used during parsing to build lists of
  654. X * identifiers that will eventually represent arguments
  655. X * to be passed to the database query programs.
  656. X */
  657. X
  658. Xtypedef struct id_list_struct {
  659. X   int                    id_count ;   /* count of IDs in the list */
  660. X   id_type * *            end_ptr_ptr ;/* pointer to link word at end of list */
  661. X   id_type *              id_list ;    /* pointer to list of IDs */
  662. X} id_list_type ;
  663. X
  664. X/* symtab_type is used to record file names in the symbol table.
  665. X */
  666. Xtypedef struct symtab_struct {
  667. X   struct symtab_struct * hash_link ;  /* list of files with same hash code */
  668. X   int                    mask_word ;  /* word in bit vector */
  669. X   unsigned long          mask_bit ;   /* bit in word */
  670. X   char                   name [ 1 ] ; /* the file name */
  671. X} symtab_type ;
  672. X
  673. Xextern void DescribeSets();
  674. Xextern id_list_type * ExtendList();
  675. Xextern void FlushSets();
  676. Xextern void InitIid();
  677. Xextern id_list_type * InitList();
  678. Xextern symtab_type * InstallFile();
  679. Xextern void OneDescription();
  680. Xextern void PrintSet();
  681. Xextern void RunPager();
  682. Xextern set_type * RunProg();
  683. Xextern void RunShell();
  684. Xextern void ScanInit();
  685. Xextern void SetDirectory();
  686. Xextern set_type * SetIntersect();
  687. Xextern set_type * SetInverse();
  688. Xextern id_list_type * SetList();
  689. Xextern set_type * SetUnion();
  690. Xextern int yylex();
  691. X
  692. X/* LidCommand is the command to run for a Lid_group. It is set
  693. X * to "lid -kmn" if explicitly preceeded by "lid", otherwise
  694. X * it is the default command which is determined by an option.
  695. X */
  696. XEXTERN char * LidCommand ;
  697. X
  698. X/* DefaultCommand is the default command for a Lid_group. If
  699. X * the -a option is given to iid, it is set to use 'aid'.
  700. X */
  701. XEXTERN char * DefaultCommand INIT("lid -kmn") ;
  702. X
  703. X/* FileList is a lexically ordered list of file symbol table
  704. X * pointers. It is dynamically expanded when necessary.
  705. X */
  706. XEXTERN symtab_type * *    FileList INIT(NULL) ;
  707. X
  708. X/* FileSpace is the number of long ints in TheFiles array.
  709. X */
  710. XEXTERN int                FileSpace INIT(0) ;
  711. X
  712. X/* HashTable is the symbol table used to store file names. Each
  713. X * new name installed is assigned the next consecutive file number.
  714. X */
  715. XEXTERN symtab_type *      HashTable [ HASH_SIZE ] ;
  716. X
  717. X/* HelpSet is a dummy set containing only one bit set which corresponds
  718. X * to the help file name. Simply a cheesy way to maximize sharing of
  719. X * the code that runs the pager.
  720. X */
  721. XEXTERN set_type *         HelpSet ;
  722. X
  723. X/* high_bit is a unsigned long with the most significant bit set.
  724. X */
  725. XEXTERN unsigned long      high_bit ;
  726. X
  727. X/* ListSpace is the amount of space avail in the FileList.
  728. X */
  729. XEXTERN int                ListSpace INIT(0) ;
  730. X
  731. X/* MaxCurFile - max word that has any bit currently set in the
  732. X * TheFiles array.
  733. X */
  734. XEXTERN int                MaxCurFile INIT(0) ;
  735. X
  736. X/* NextFileNum is the file number that will be assigned to the next
  737. X * new file name seen when it is installed in the symtab.
  738. X */
  739. XEXTERN int                NextFileNum INIT(0) ;
  740. X
  741. X/* NextMaskBit is the bit within the next mask word that will
  742. X * correspond to the next file added to the symbol table.
  743. X */
  744. XEXTERN unsigned long      NextMaskBit ;
  745. X
  746. X/* NextMaskWord is the next word number to be assigned to a file
  747. X * bit mask entry.
  748. X */
  749. XEXTERN int                NextMaskWord INIT(0) ;
  750. X
  751. X/* NextSetNum is the number that will be assigned to the next set
  752. X * created. Starts at 0 because I am a C programmer.
  753. X */
  754. XEXTERN int                NextSetNum INIT(0) ;
  755. X
  756. X/* The PAGER program to run on a SHOW command.
  757. X */
  758. XEXTERN char               Pager[MAXCMD] ;
  759. X
  760. X/* Prompt - the string to use for a prompt.
  761. X */
  762. XEXTERN char               Prompt[MAXCMD] ;
  763. X
  764. X/* SetSpace is the number of pointers available in TheSets. TheSets
  765. X * is realloced when we run out of space.
  766. X */
  767. XEXTERN int                SetSpace INIT(0) ;
  768. X
  769. X/* TheFiles is a bit set used to construct the initial set of files
  770. X * generated while running one of the subprograms. It is copied to
  771. X * the alloced set once we know how many bits are set.
  772. X */
  773. XEXTERN unsigned long *    TheFiles INIT(NULL) ;
  774. X
  775. X/* TheSets is a dynamically allocated array of pointers pointing
  776. X * the sets that have been allocated. It represents the set of
  777. X * sets.
  778. X */
  779. XEXTERN set_type * *       TheSets INIT(NULL) ;
  780. X
  781. X/* VerboseQuery controls the actions of the semantic routines during
  782. X * the process of a query. If TRUE the sets are described as they
  783. X * are constructed.
  784. X */
  785. XEXTERN int                VerboseQuery ;
  786. END_OF_FILE
  787. if test 6331 -ne `wc -c <'iiddef.h'`; then
  788.     echo shar: \"'iiddef.h'\" unpacked with wrong size!
  789. fi
  790. # end of 'iiddef.h'
  791. fi
  792. if test -f 'lid.1' -a "${1}" != "-c" ; then 
  793.   echo shar: Will not clobber existing file \"'lid.1'\"
  794. else
  795. echo shar: Extracting \"'lid.1'\" \(5678 characters\)
  796. sed "s/^X//" >'lid.1' <<'END_OF_FILE'
  797. X.TH LID 1
  798. X.SH NAME
  799. Xlid, gid, eid, aid, pid \- query id database
  800. X.SH SYNOPSIS
  801. X.B lid
  802. X.RB [ \-f \^file]
  803. X.RB [ \-u \^n]
  804. X.RB [ \-r \^dir]
  805. X.RB [ \-edoxamseknc]
  806. Xpatterns...
  807. X.PP
  808. X.B gid
  809. X.RB [ \-f \^file]
  810. X.RB [ \-r \^dir]
  811. X.RB [ \-edoxamsec]
  812. Xpatterns...
  813. X.PP
  814. X.B eid
  815. X.RB [ \-f \^file]
  816. X.RB [ \-r \^dir]
  817. X.RB [ \-doxamsec]
  818. Xpatterns...
  819. X.PP
  820. X.B aid
  821. X.RB [ \-f \^file]
  822. X.RB [ \-r \^dir]
  823. X.RB [ \-doxamsc]
  824. Xpatterns...
  825. X.PP
  826. X.B pid
  827. X.RB [ \-f \^file]
  828. X.RB [ \-r \^dir]
  829. X.RB [ \-ekncb]
  830. Xpatterns...
  831. X.SH DESCRIPTION
  832. XThese commands provide a flexible query interface to the
  833. X.I id
  834. Xdatabase.
  835. X.I Lid\^
  836. Xdoes a lookup on
  837. X.IR patters
  838. Xand prints out lines in this way:
  839. X.PP
  840. X.nf
  841. Xidname        ../hdir/hfile.h ../cdir/{cfile1,cfile2}.c
  842. X.fi
  843. X.PP
  844. XNotice that multiple files with the same directory prefix
  845. Xand suffix are concatenated in the globbing-set-notation of
  846. X.IR csh (1).
  847. XAlso notice that all of the
  848. X.I id
  849. Xdatabase query commands adjust the list of pathnames to be relative
  850. Xto your current working directory, provided that
  851. X.IR mkid (1)
  852. Xwas used to build the database, and your working directory
  853. Xis located within the sub-tree covered by the
  854. X.I id
  855. Xdatabase.
  856. X.PP
  857. XIf multiple names match on pattern, then there will be one line
  858. Xof output per name.  The mnemonic significance of the name is
  859. X\fI\|l(ookup) id\fP.
  860. X.PP
  861. X.I Gid
  862. Xdoes a lookup and then searches for the names it matches in the
  863. Xfiles where they occur.  The mnemonic for this name is
  864. X\fI\|g(rep)id\fP. 
  865. X.PP
  866. X.I Eid
  867. Xdoes a lookup, and then invokes an editor on all files with
  868. Xthe matched name as an initial search string.  Of course, this
  869. Xname stands for
  870. X\fI\|e(dit) id\fP.
  871. X.PP
  872. X.I Eid
  873. Xuses four environment variables to control its invocation of the
  874. Xeditor.
  875. XNaturally,
  876. X.B EDITOR
  877. Xis used to locate the editing program.
  878. X.B EIDARG
  879. Xis a
  880. X.IR printf (3S)
  881. Xstring used to specify the form of the initial-search-string
  882. Xargument.  If the editor does not support such an argument,
  883. Xthis variable may be left unset.
  884. X.B EIDLDEL
  885. Xand
  886. X.B EIDRDEL
  887. Xspecify the form of the left and right word-delimiters respectively.
  888. XThe best way to explain the use of these last three variables is
  889. Xwith an example.  Here are the proper settings for vi(1):
  890. X.nf
  891. XEIDARG='+/%s/'    # initial search argument template
  892. XEIDLDEL='\\<'    # left word-delimiter
  893. XEIDRDEL='\\>'    # right word-delimiter
  894. X.fi
  895. X.PP
  896. X.I Patterns
  897. Xmay be simple alpha-numeric strings, or regular expressions in the
  898. Xstyle of
  899. X.IR regcmp (3).
  900. XIf the string contains no regular-expression meta-characters, it is
  901. Xsearched for as a
  902. X.IR word .
  903. XIf the string contains meta-characters, or if the \-e argument is
  904. Xsupplied, it is searched for as regular-expression.
  905. X.PP
  906. X.I Aid\^
  907. Xproduces output in the style of
  908. X.I lid\^
  909. Xbut its pattern arguments are searched for as substrings within
  910. Xthe identifiers in the database.  No regular-expression search
  911. Xis performed, even if the pattern contains meta-characters.
  912. XThe search is conducted in an alphabetic case insensitive manner.
  913. XThe mnemonic for this name is
  914. X\fI\|a(propos) id\fP. 
  915. X.PP
  916. X.I Pid\^
  917. Xis used to match the input patterns against the names of the files
  918. Xin the database rather than the contents of the files. The pattern
  919. Xis assumed to be a simple shell wild card pattern unless the
  920. X.B \-e
  921. Xoption is given, in which case full regular expression matching
  922. Xis used.
  923. XThe
  924. X.B \-b
  925. Xoption can be used to restrict the match to just the basename portion
  926. Xof the full absolute path name of the file.
  927. XThe mnemonic for this name is
  928. X\fI\|p(ath) id\fP. 
  929. X.PP
  930. XThe following options are recognized:
  931. X.TP 10
  932. X.BR \-f file\^
  933. XUse
  934. X.I file\^
  935. Xas the database instead of the default
  936. X.BR ID .
  937. X.TP 10
  938. X.BR \-u n
  939. XLists all identifiers in the database that are non-unique within the first
  940. X.I n
  941. Xcharacters.  This facility is particularly helpful when porting a program
  942. Xto a system whose compiler or linker has fewer significant characters
  943. Xfor identifiers.
  944. X.TP 10
  945. X.BR \-r dir\^
  946. XAssume the names stored in the database are relative to this directory.
  947. XThis option is useful if you create the database in one place, then move
  948. Xit somewhere else. Normally all the query tools assume the names in
  949. Xthe database are relative to the location of the database.
  950. X.TP 10
  951. X.B \-c
  952. XThis option is similar to
  953. X.BR \-r ,
  954. Xbut it tells the id query tool to assume the names in the ID database
  955. Xare stored relative to the current working directory.
  956. X.TP 10
  957. X.B \-k
  958. XSuppresses the use of \fL{\fP and \fL}\fP as a shorthand in the
  959. Xgenerated list of file names. Each name is output in full.
  960. X.TP 10
  961. X.B \-n
  962. XSuppresses printing the name of the search string, only the names of
  963. Xthe files containing the string are printed. Together with the \fB\-k\fP
  964. Xoption this can be used to generate lists of files to pass to other
  965. Xprograms.
  966. X.PP
  967. X.TP 10
  968. X.B \-b
  969. XIn the
  970. X.I pid
  971. Xprogram, the
  972. X.B \-b
  973. Xoption is used to force pattern matching on just the base names of the
  974. Xfile, otherwise the pattern matching is done on the full absolute file
  975. Xname.
  976. X.PP
  977. XThe remaining options are for use in conjunction with numeric patterns:
  978. X.TP 10
  979. X.B \-doxa
  980. XThese options may be specified in any combination.
  981. XThey limit numeric matches to specific radixes.
  982. XThe
  983. X.BR \-d ,
  984. X.BR \-o ,
  985. Xand
  986. X.B \-x
  987. Xoptions limit matches to decimal, octal, and hexadecimal respectively.
  988. XThe
  989. X.BR \-a
  990. Xoption is a shorthand for specifying all three radixes.
  991. X.PP
  992. XSearches for numbers 
  993. Xare conducted numerically rather than lexically, so that all
  994. Xrepresentations for a given number are potentially available
  995. Xfrom a single search.
  996. X.TP 10
  997. X.B \-m
  998. XMerge multiple lines of output into a single line.
  999. X.TP 10
  1000. X.B \-s
  1001. XLimit the results of the search to identifiers that occur only
  1002. Xonce in the entire set of sources covered by the database.
  1003. XThis option is useful for finding identifiers that are defined
  1004. Xbut never used.
  1005. X.SH SEE ALSO
  1006. Xmkid(1),
  1007. Xfid(1).
  1008. END_OF_FILE
  1009. if test 5678 -ne `wc -c <'lid.1'`; then
  1010.     echo shar: \"'lid.1'\" unpacked with wrong size!
  1011. fi
  1012. # end of 'lid.1'
  1013. fi
  1014. if test -f 'scan-asm.c' -a "${1}" != "-c" ; then 
  1015.   echo shar: Will not clobber existing file \"'scan-asm.c'\"
  1016. else
  1017. echo shar: Extracting \"'scan-asm.c'\" \(6157 characters\)
  1018. sed "s/^X//" >'scan-asm.c' <<'END_OF_FILE'
  1019. X/* Copyright (c) 1986, Greg McGary */
  1020. Xstatic char sccsid[] = "@(#)scan-asm.c    1.2 86/11/06";
  1021. X
  1022. X#include    <bool.h>
  1023. X#include    <stdio.h>
  1024. X#include    <string.h>
  1025. X#include    <ctype.h>
  1026. X#include    <id.h>
  1027. X
  1028. Xchar *getAsmId();
  1029. Xvoid setAsmArgs();
  1030. X
  1031. Xstatic void clrCtype();
  1032. Xstatic void setCtype();
  1033. X
  1034. X#define    I1    0x01    /* 1st char of an identifier [a-zA-Z_] */
  1035. X#define    NM    0x02    /* digit [0-9a-fA-FxX] */
  1036. X#define    NL    0x04    /* newline: \n */
  1037. X#define    CM    0x08    /* assembler comment char: usually # or | */
  1038. X#define    IG    0x10    /* ignore `identifiers' with these chars in them */
  1039. X#define    C1    0x20    /* C comment introduction char: / */
  1040. X#define    C2    0x40    /* C comment termination  char: * */
  1041. X#define    EF    0x80    /* EOF */
  1042. X
  1043. X/* Assembly Language character classes */
  1044. X#define    ISID1ST(c)    ((rct)[c]&(I1))
  1045. X#define    ISIDREST(c)    ((rct)[c]&(I1|NM))
  1046. X#define    ISNUMBER(c)    ((rct)[c]&(NM))
  1047. X#define    ISEOF(c)    ((rct)[c]&(EF))
  1048. X#define    ISCOMMENT(c)    ((rct)[c]&(CM))
  1049. X#define    ISBORING(c)    (!((rct)[c]&(EF|NL|I1|NM|CM|C1)))
  1050. X#define    ISCBORING(c)    (!((rct)[c]&(EF|NL)))
  1051. X#define    ISCCBORING(c)    (!((rct)[c]&(EF|C2)))
  1052. X#define    ISIGNORE(c)    ((rct)[c]&(IG))
  1053. X
  1054. Xstatic char idctype[] = {
  1055. X
  1056. X    EF,
  1057. X
  1058. X    /*      0       1       2       3       4       5       6       7   */
  1059. X    /*    -----   -----   -----   -----   -----   -----   -----   ----- */
  1060. X
  1061. X    /*000*/    0,    0,    0,    0,    0,    0,    0,    0,
  1062. X    /*010*/    0,    0,    NL,    0,    0,    0,    0,    0,
  1063. X    /*020*/    0,    0,    0,    0,    0,    0,    0,    0,
  1064. X    /*030*/    0,    0,    0,    0,    0,    0,    0,    0,
  1065. X    /*040*/    0,    0,    0,    0,    0,    0,    0,    0,
  1066. X    /*050*/    0,    0,    C2,    0,    0,    0,    0,    C1,
  1067. X    /*060*/    NM,    NM,    NM,    NM,    NM,    NM,    NM,    NM,    
  1068. X    /*070*/    NM,    NM,    0,    0,    0,    0,    0,    0,
  1069. X    /*100*/    0,    I1|NM,    I1|NM,    I1|NM,    I1|NM,    I1|NM,    I1|NM,    I1,
  1070. X    /*110*/    I1,    I1,    I1,    I1,    I1|NM,    I1,    I1,    I1,
  1071. X    /*120*/    I1,    I1,    I1,    I1,    I1,    I1,    I1,    I1,
  1072. X    /*130*/    I1|NM,    I1,    I1,    0,    0,    0,    0,    I1,
  1073. X    /*140*/    0,    I1|NM,    I1|NM,    I1|NM,    I1|NM,    I1|NM,    I1|NM,    I1,
  1074. X    /*150*/    I1,    I1,    I1,    I1,    I1|NM,    I1,    I1,    I1,
  1075. X    /*160*/    I1,    I1,    I1,    I1,    I1,    I1,    I1,    I1,
  1076. X    /*170*/    I1|NM,    I1,    I1,    0,    0,    0,    0,    0,
  1077. X
  1078. X    /*200*/    0,    0,    0,    0,    0,    0,    0,    0,
  1079. X    /*210*/    0,    0,    0,    0,    0,    0,    0,    0,
  1080. X    /*220*/    0,    0,    0,    0,    0,    0,    0,    0,
  1081. X    /*230*/    0,    0,    0,    0,    0,    0,    0,    0,
  1082. X    /*240*/    0,    0,    0,    0,    0,    0,    0,    0,
  1083. X    /*250*/    0,    0,    0,    0,    0,    0,    0,    0,
  1084. X    /*260*/    0,    0,    0,    0,    0,    0,    0,    0,
  1085. X    /*270*/    0,    0,    0,    0,    0,    0,    0,    0,
  1086. X    /*300*/    0,    0,    0,    0,    0,    0,    0,    0,
  1087. X    /*310*/    0,    0,    0,    0,    0,    0,    0,    0,
  1088. X    /*320*/    0,    0,    0,    0,    0,    0,    0,    0,
  1089. X    /*330*/    0,    0,    0,    0,    0,    0,    0,    0,
  1090. X    /*340*/    0,    0,    0,    0,    0,    0,    0,    0,
  1091. X    /*350*/    0,    0,    0,    0,    0,    0,    0,    0,
  1092. X    /*360*/    0,    0,    0,    0,    0,    0,    0,    0,
  1093. X    /*370*/    0,    0,    0,    0,    0,    0,    0,    0,
  1094. X
  1095. X};
  1096. X
  1097. Xstatic bool eatUnder = TRUE;
  1098. Xstatic bool preProcess = TRUE;
  1099. X
  1100. X/*
  1101. X    Grab the next identifier the assembly language
  1102. X    source file opened with the handle `inFILE'.
  1103. X    This state machine is built for speed, not elegance.
  1104. X*/
  1105. Xchar *
  1106. XgetAsmId(inFILE, flagP)
  1107. X    FILE        *inFILE;
  1108. X    int        *flagP;
  1109. X{
  1110. X    static char    idBuf[BUFSIZ];
  1111. X    register char    *rct = &idctype[1];
  1112. X    register int    c;
  1113. X    register char    *id = idBuf;
  1114. X    static bool    newLine = TRUE;
  1115. X
  1116. Xtop:
  1117. X    c = getc(inFILE);
  1118. X    if (preProcess > 0 && newLine) {
  1119. X        newLine = FALSE;
  1120. X        if (c != '#')
  1121. X            goto next;
  1122. X        while (ISBORING(c))
  1123. X            c = getc(inFILE);
  1124. X        if (!ISID1ST(c))
  1125. X            goto next;
  1126. X        id = idBuf;
  1127. X        *id++ = c;
  1128. X        while (ISIDREST(c = getc(inFILE)))
  1129. X            *id++ = c;
  1130. X        *id = '\0';
  1131. X        if (strequ(idBuf, "include")) {
  1132. X            while (c != '"' && c != '<')
  1133. X                c = getc(inFILE);
  1134. X            id = idBuf;
  1135. X            *id++ = c = getc(inFILE);
  1136. X            while ((c = getc(inFILE)) != '"' && c != '>')
  1137. X                *id++ = c;
  1138. X            *id = '\0';
  1139. X            *flagP = IDN_STRING;
  1140. X            return idBuf;
  1141. X        }
  1142. X        if (strnequ(idBuf, "if", 2)
  1143. X        || strequ(idBuf, "define")
  1144. X        || strequ(idBuf, "undef"))
  1145. X            goto next;
  1146. X        while (c != '\n')
  1147. X            c = getc(inFILE);
  1148. X        newLine = TRUE;
  1149. X        goto top;
  1150. X    }
  1151. X
  1152. Xnext:
  1153. X    while (ISBORING(c))
  1154. X        c = getc(inFILE);
  1155. X
  1156. X    if (ISCOMMENT(c)) {
  1157. X        while (ISCBORING(c))
  1158. X            c = getc(inFILE);
  1159. X        newLine = TRUE;
  1160. X    }
  1161. X
  1162. X    if (ISEOF(c)) {
  1163. X        newLine = TRUE;
  1164. X        return NULL;
  1165. X    }
  1166. X
  1167. X    if (c == '\n') {
  1168. X        newLine = TRUE;
  1169. X        goto top;
  1170. X    }
  1171. X
  1172. X    if (c == '/') {
  1173. X        if ((c = getc(inFILE)) != '*')
  1174. X            goto next;
  1175. X        c = getc(inFILE);
  1176. X        for (;;) {
  1177. X            while (ISCCBORING(c))
  1178. X                c = getc(inFILE);
  1179. X            if ((c = getc(inFILE)) == '/') {
  1180. X                c = getc(inFILE);
  1181. X                break;
  1182. X            } else if (ISEOF(c)) {
  1183. X                newLine = TRUE;
  1184. X                return NULL;
  1185. X            }
  1186. X        }
  1187. X        goto next;
  1188. X    }
  1189. X
  1190. X    id = idBuf;
  1191. X    if (eatUnder && c == '_' && !ISID1ST(c = getc(inFILE))) {
  1192. X        ungetc(c, inFILE);
  1193. X        return "_";
  1194. X    }
  1195. X    *id++ = c;
  1196. X    if (ISID1ST(c)) {
  1197. X        *flagP = IDN_NAME;
  1198. X        while (ISIDREST(c = getc(inFILE)))
  1199. X            *id++ = c;
  1200. X    } else if (ISNUMBER(c)) {
  1201. X        *flagP = IDN_NUMBER;
  1202. X        while (ISNUMBER(c = getc(inFILE)))
  1203. X            *id++ = c;
  1204. X    } else {
  1205. X        if (isprint(c))
  1206. X            fprintf(stderr, "junk: `%c'", c);
  1207. X        else
  1208. X            fprintf(stderr, "junk: `\\%03o'", c);
  1209. X        goto next;
  1210. X    }
  1211. X
  1212. X    *id = '\0';
  1213. X    for (id = idBuf; *id; id++)
  1214. X        if (ISIGNORE(*id))
  1215. X            goto next;
  1216. X    ungetc(c, inFILE);
  1217. X    *flagP |= IDN_LITERAL;
  1218. X    return idBuf;
  1219. X}
  1220. X
  1221. Xstatic void
  1222. XsetCtype(chars, type)
  1223. X    char        *chars;
  1224. X    int        type;
  1225. X{
  1226. X    char        *rct = &idctype[1];
  1227. X
  1228. X    while (*chars)
  1229. X        rct[*chars++] |= type;
  1230. X}
  1231. Xstatic void
  1232. XclrCtype(chars, type)
  1233. X    char        *chars;
  1234. X    int        type;
  1235. X{
  1236. X    char        *rct = &idctype[1];
  1237. X
  1238. X    while (*chars)
  1239. X        rct[*chars++] &= ~type;
  1240. X}
  1241. X
  1242. Xextern char    *MyName;
  1243. Xstatic void
  1244. Xusage(lang)
  1245. X    char        *lang;
  1246. X{
  1247. X    fprintf(stderr, "Usage: %s -S%s([-c<cc>] [-u] [(+|-)a<cc>] [(+|-)p] [(+|-)C])\n", MyName, lang);
  1248. X    exit(1);
  1249. X}
  1250. Xstatic char *asmDocument[] =
  1251. X{
  1252. X"The Assembler scanner arguments take the form -Sasm<arg>, where",
  1253. X"<arg> is one of the following: (<cc> denotes one or more characters)",
  1254. X"  -c<cc> . . . . <cc> introduce(s) a comment until end-of-line.",
  1255. X"  (+|-)u . . . . (Do|Don't) strip a leading `_' from ids.",
  1256. X"  (+|-)a<cc> . . Allow <cc> in ids, and (keep|ignore) those ids.",
  1257. X"  (+|-)p . . . . (Do|Don't) handle C-preprocessor directives.",
  1258. X"  (+|-)C . . . . (Do|Don't) handle C-style comments. (/* */)",
  1259. XNULL
  1260. X};
  1261. Xvoid
  1262. XsetAsmArgs(lang, op, arg)
  1263. X    char        *lang;
  1264. X    int        op;
  1265. X    char        *arg;
  1266. X{
  1267. X    if (op == '?') {
  1268. X        document(asmDocument);
  1269. X        return;
  1270. X    }
  1271. X    switch (*arg++)
  1272. X    {
  1273. X    case 'a':
  1274. X        setCtype(arg, I1|((op == '-') ? IG : 0));
  1275. X        break;
  1276. X    case 'c':
  1277. X        setCtype(arg, CM);
  1278. X        break;
  1279. X    case 'u':
  1280. X        eatUnder = (op == '+');
  1281. X        break;
  1282. X    case 'p':
  1283. X        preProcess = (op == '+');
  1284. X        break;
  1285. X    case 'C':
  1286. X        if (op == '+') {
  1287. X            setCtype("/", C1);
  1288. X            setCtype("*", C2);
  1289. X        } else {
  1290. X            clrCtype("/", C1);
  1291. X            clrCtype("*", C2);
  1292. X        }
  1293. X        break;
  1294. X    default:
  1295. X        if (lang)
  1296. X            usage(lang);
  1297. X        break;
  1298. X    }
  1299. X}
  1300. END_OF_FILE
  1301. if test 6157 -ne `wc -c <'scan-asm.c'`; then
  1302.     echo shar: \"'scan-asm.c'\" unpacked with wrong size!
  1303. fi
  1304. # end of 'scan-asm.c'
  1305. fi
  1306. echo shar: End of archive 3 \(of 7\).
  1307. cp /dev/null ark3isdone
  1308. MISSING=""
  1309. for I in 1 2 3 4 5 6 7 ; do
  1310.     if test ! -f ark${I}isdone ; then
  1311.     MISSING="${MISSING} ${I}"
  1312.     fi
  1313. done
  1314. if test "${MISSING}" = "" ; then
  1315.     echo You have unpacked all 7 archives.
  1316.     rm -f ark[1-9]isdone
  1317. else
  1318.     echo You still need to unpack the following archives:
  1319.     echo "        " ${MISSING}
  1320. fi
  1321. ##  End of shell archive.
  1322. exit 0
  1323.  
  1324. exit 0 # Just in case...
  1325.